package pogvue.gui.popups;

import pogvue.gui.AlignViewport;
import pogvue.gui.Controller;
import pogvue.gui.event.AlignViewportEvent;

import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;

public class PercentIdentityPopup extends ThresholdPopup {

  public PercentIdentityPopup(JPanel parent, AlignViewport av, Controller c, String title, String label, int low, int high, int value) {
    super(parent,av,c,title,label,low,high,value);

    status.setText("Enter the threshold above which to colour sequences");
    gbc.fill = GridBagConstraints.NONE;

    gbc.insets = new Insets(20,20,20,20);
    add(tp,gb,gbc,0,0,2,1);
    add(status,gb,gbc,0,1,2,1);
    add(apply,gb,gbc,0,2,1,1);
    add(close,gb,gbc,1,2,1,1);

    setApplyAction(new PercentIdentityAction("percent identity",av,c));

    pack();
    show();
  }

  public class PercentIdentityAction extends ThresholdAction {
    public PercentIdentityAction(String name, AlignViewport av,Controller c) {
      super(name,av,c);
    }

    public void applyAction(ActionEvent evt) {
      int threshold = getThreshold();

//      if (parent instanceof AlignFrame) {
//        AlignFrame af = (AlignFrame)parent;
        av.setThreshold(threshold);
//        af.ap.setSequenceColor(threshold,ColourAdapter.get(af.getScheme()));
//        af.updateFont();
        controller.handleAlignViewportEvent(new AlignViewportEvent(this,av,AlignViewportEvent.THRESHOLD));
//      }
    }
  }
}
